import { _decorator, EventTouch, Node } from "cc";
import { ecs } from "db://app-game/libs/ecs/ECS";
import { CCComp } from "db://app-game/module/common/CCComp";
import { Role } from "../../../ecs/role/Role";
import { Level } from "../Level";

const { ccclass, property } = _decorator;

/** 关卡视图组件 */
@ccclass("LevelViewComp")
@ecs.register("LevelView", false)
export class LevelViewComp extends CCComp {
  /** 关卡背景层视图 */
  layerGame: Node = null!;
  /** 关卡地图层视图 */
  tiledMap: Node = null!;
  /** 生物节点视图 */
  creatureNode: Node = null!;
  /** UI 节点视图 */
  uiNode: Node = null!;
  /** 角色节点视图 */
  role: Role = null!;
  protected onLoad(): void {
    let level = this.ent as Level;

    this.layerGame = this.node.getChildByName("layer-game")!;
    this.tiledMap = this.layerGame.getChildByName("map")!;
    this.creatureNode = this.layerGame.getChildByName("creature")!;
    this.uiNode = this.node.getChildByName("ui")!;
  }

  private btn_attack(event: EventTouch, data: any) {
    this.ent.children.forEach((e) => {
      // e.attack();
    });
  }
  reset(ent: ecs.Entity): void {}
}
